using System;
using System.Data;

using SqlHelperForCry.Common;

namespace Torch.WL.Entity
{
    [Table("Tb_RewardGrant", "grantId", "Torch.WL.ConnectionString")]
	public class Tb_RewardGrant : Info
	{
		#region SQL column name consts 
		public const string SQLCOL_GRANTID = "grantId";
		public const string SQLCOL_REWARDID = "rewardId";
		public const string SQLCOL_COMPANYID = "companyId";
		public const string SQLCOL_SORTINDEX = "sortindex";
		#endregion


		#region Contructors
		/// <summary>
		/// Construct empty entity
		/// </summary>
		public Tb_RewardGrant () {}

		/// <summary>
		/// Construct entity by primary key, other fields will be assigned by 
		/// "Load" method.
		/// </summary>
		public Tb_RewardGrant (int grantId)
		{
			this.grantId = grantId;
		}
		#endregion

		public override void Init (DataRow row)
		{
			grantId = (int)ObjectType.IntTypeHelper.Read(row[SQLCOL_GRANTID]);
			rewardId = (int)ObjectType.IntTypeHelper.Read(row[SQLCOL_REWARDID]);
			companyId = (int)ObjectType.IntTypeHelper.Read(row[SQLCOL_COMPANYID]);
			sortindex = (int)ObjectType.IntTypeHelper.Read(row[SQLCOL_SORTINDEX]);
		}

		#region Properties 
		#region Property <int> grantId
		[Property("grantId", 4, SqlDbType.Int, true, true)]
		public int grantId 
		{
			get { return _grantId; }
			set { _grantId = value; }
		}
		private int _grantId = int.MinValue;
		#endregion

		#region Property <int> rewardId
		[Property("rewardId", 4, SqlDbType.Int, false, false)]
		public int rewardId 
		{
			get { return _rewardId; }
			set { _rewardId = value; }
		}
		private int _rewardId = int.MinValue;
		#endregion

		#region Property <int> companyId
		[Property("companyId", 4, SqlDbType.Int, false, false)]
		public int companyId 
		{
			get { return _companyId; }
			set { _companyId = value; }
		}
		private int _companyId = int.MinValue;
		#endregion

		#region Property <int> sortindex
		[Property("sortindex", 4, SqlDbType.Int, false, false)]
		public int sortindex 
		{
			get { return _sortindex; }
			set { _sortindex = value; }
		}
		private int _sortindex = int.MinValue;
		#endregion
		#endregion


		public bool LoadByIdentity(int grantId)
		{
			return DataAccess.SelectByIdentity(this, Convert.ToInt64(grantId));
		}


		public bool DeleteByIdentity()
		{
			return DataAccess.DeleteByIdentity(this);
		}
	}
}
